package com.pr.makfilm.domain;

import org.hibernate.validator.constraints.Length;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * Created with IntelliJ IDEA.
 * User: Pawel
 * Date: 17.09.13
 * Time: 20:12
 * To change this template use File | Settings | File Templates.
 */
@Entity
@Table(name = "contact_person")
public class ContactPerson extends IdentifiableEntity
{
   public static final String FIELD_FIRST_NAME = "firstName";

   public static final String FIELD_LAST_NAME = "lastName";

   public static final String FIELD_PHONE = "phone";

   public static final String FIELD_EMAIL = "email";

   public static final String FIELD_SCHOOL = "school";

   public static final int MAX_LENGTH_FIRST_NAME = 25;

   public static final int MAX_LENGTH_LAST_NAME = 35;

   public static final int MAX_LENGTH_PHONE = 9;

   public static final int MAX_LENGTH_EMAIL = 35;

   @Id
   @GeneratedValue
   @Column
   private Long id;

   @Column(name = "first_name", nullable = false, length = MAX_LENGTH_FIRST_NAME)
   @NotNull
   @Length(max = MAX_LENGTH_FIRST_NAME)
   private String firstName;

   @Column(name = "last_name", nullable = false, length = MAX_LENGTH_LAST_NAME)
   @NotNull
   @Length(max = MAX_LENGTH_LAST_NAME)
   private String lastName;

   @Column(nullable = true, length = MAX_LENGTH_PHONE)
   @Length(max = MAX_LENGTH_PHONE)
   private String phone;

   @Column(nullable = true, length = MAX_LENGTH_EMAIL)
   @Length(max = MAX_LENGTH_EMAIL)
   private String email;

   @ManyToOne(cascade = {CascadeType.MERGE, CascadeType.PERSIST}, fetch = FetchType.LAZY)
   @JoinColumn(nullable = false)
   @NotNull
   private School school;

   public Long getId()
   {
      return id;
   }

   public void setId(Long id)
   {
      this.id = id;
   }

   public String getFirstName()
   {
      return firstName;
   }

   public void setFirstName(String firstName)
   {
      this.firstName = firstName;
   }

   public String getLastName()
   {
      return lastName;
   }

   public void setLastName(String lastName)
   {
      this.lastName = lastName;
   }

   public String getPhone()
   {
      return phone;
   }

   public void setPhone(String phone)
   {
      this.phone = phone;
   }

   public String getEmail()
   {
      return email;
   }

   public void setEmail(String email)
   {
      this.email = email;
   }

   public School getSchool()
   {
      return school;
   }

   public void setSchool(School school)
   {
      this.school = school;
   }
}
